#pragma once
#include "rga/rga.h"
// #include "rga/im2d.h"
#include "rga/im2d.hpp"
#include "rga/im2d_type.h"
#include "rga/RgaUtils.h"
#include "log/log.h"

class SmartRga {
public:
    typedef struct {
        int width;
        int height;
        RgaSURF_FORMAT format;
        uint8_t* buffer;
    } cfg_t;

public:
    SmartRga() {};
    ~SmartRga() {deinit();}
    int init(cfg_t src_cfg, cfg_t dst_cfg);
    int config_src(cfg_t cfg);
    int config_dst(cfg_t cfg);
    int deinit();
    int resize();
    int cvtcolor();
    static int get_image_size(int width, int height, RgaSURF_FORMAT format);

private:
    cfg_t m_src_cfg;
    cfg_t m_dst_cfg;

    im_rect m_src_rect;
    im_rect m_dst_rect;
    rga_buffer_t m_src;
    rga_buffer_t m_dst;
    rga_buffer_handle_t m_src_handle{(uint32_t)-1};
    rga_buffer_handle_t m_dst_handle{(uint32_t)-1};
};